package DAO;

import java.sql.*;

/**
 * Contains the info to connect to the database
 * @author Jason, Sam and Joshua
 */
public class MySQLDAOFactory extends DAOFactory {

    private static final String USERNAME = "3120S109g05";
    private static final String PASSWORD = "a44852c71d";
    public static String URL = "jdbc:mysql://dunk.cs.jcu.edu.au:3306/" + USERNAME; //might not need port
    public static final String DRIVER = "com.mysql.jdbc.Driver";
    static Connection con;

    public MySQLDAOFactory() {
    }

    public MySQLDAOFactory(String databaseLocation) {
        URL = databaseLocation + USERNAME;
    }

    /**
     * Function to connect to the database
     * @return con
     */
    public static Connection createConnection() {
        try {
            Class.forName(DRIVER);
            con = DriverManager.getConnection(URL, USERNAME, PASSWORD);
        } catch (Exception e) {
            return null;
        //e.printStackTrace();
        }
        return con;
    }

    public AccountDAO getAccountDAO() {
        return new MySQLAccountDAO();
    }

    public FlightDAO getFlightDAO() {
        return new MySQLFlightDAO();
    }
}
